﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


/// <summary>
/// FlowStep 流程步骤操作类
/// </summary>
public class FlowStep
{
    public int FlowMID;
    public string StepName;
    public int SEQ;
    public string UserIDList;
    public int DepID;
    public string Content;
    public int LCBZMID;
    public string Status;
    public DateTime AddTime;
	public FlowStep()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
    }
    public FlowStep(int lcbzid)
    {
        this.LCBZMID = lcbzid;
        string sqlString = "select * from LCBZMINFO where LCBZMID=" +this.LCBZMID.ToString();
        DBOperation DBO = new DBOperation();
        SqlDataReader sdr = DBO.GetDataReader(sqlString);
        if (sdr.Read())
        {
            this.FlowMID = Convert.ToInt32(sdr["FLOWMID"].ToString());
            this.StepName = sdr["STEPNAME"].ToString();
            this.SEQ = Convert.ToInt32(sdr["SEQ"].ToString());
            this.Content = sdr["CONTENT"].ToString();
            this.AddTime = Convert.ToDateTime(sdr["ADDTIME"].ToString());
            this.Status = sdr["STATUS"].ToString();
            this.DepID = Convert.ToInt32(sdr["DEPID"].ToString());
            this.UserIDList = sdr["USERIDLIST"].ToString();
        }
        sdr.Close();

    }
    /// <summary>
    /// 方法AddFlowStep() 用于添加流程步骤
    /// </summary>
    /// <returns>成功则返回True，否则返回False</returns>
    public Boolean AddFlowStep()
    {
        string sqlString = "insert into LCBZMINFO (FLOWMID,SEQ,STEPNAME,USERIDLIST,DEPID,CONTENT,STATUS) values (";
        sqlString += this.FlowMID.ToString() + "," + this.SEQ.ToString() + ",'" + this.StepName + "','" + this.UserIDList + "',"+this.DepID.ToString()+",'" + this.Content + "','1')";
        DBOperation DBO = new DBOperation();
        if (DBO.ExcuteSql(sqlString))
        {
            return true;
        }
        else
        {
            return false;
        }
 
    }
    public Boolean DelFlowStep()
    {
        bool success = false;
        string sqlString = "delete from LCBZMINFO where LCBZMID=" + this.LCBZMID.ToString();
        DBOperation DBO = new DBOperation();
        success = DBO.ExcuteSql(sqlString);
        return success; 
    }
    public Boolean UpdateFlowStep()
    {
        string sqlString = "update LCBZMINFO set SEQ=" + this.SEQ.ToString() + ",STEPNAME='" + this.StepName + "',USERIDLIST='" + this.UserIDList + "',CONTENT='" + this.Content + "',STATUS='" + this.Status + "',DEPID=" + this.DepID.ToString() + " where LCBZMID="+this.LCBZMID+"";
        DBOperation DBO = new DBOperation();
        if (DBO.ExcuteSql(sqlString))
        {
            return true;
        }
        else
        {
            return false;
        }

    }
}
